<?php

//理论上，公钥用来加密，私钥用来解密
require_once "rsa.php";
$rsa = new Rsa();
$data['name'] = 'zof';
$data['age']  = '18';
$privEncrypt = $rsa->privEncrypt(json_encode($data));
echo '私钥加密后:'.$privEncrypt."\n";

$publicDecrypt = $rsa->publicDecrypt($privEncrypt);
echo '公钥解密后:'.$publicDecrypt."\n";
$data = [];
$data['access_token'] = 'ACCESS_TOKEN';
$data['code'] = 'CODE';
echo "\n--------------\n";
echo json_encode($data);
echo "\n--------------\n";

$publicEncrypt = $rsa->publicEncrypt(json_encode($data));
echo '公钥加密后:'.$publicEncrypt."\n";

$privDecrypt = $rsa->privDecrypt($publicEncrypt);
echo '私钥解密后:'.$privDecrypt."\n";